package com.huawei.appmarket.framework.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
import androidx.annotation.Nullable;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSViewProxy;
import com.huawei.appgallery.foundation.ui.css.RenderListener;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import o.epo;
import o.ewm.e;

public class RenderMachineImageView extends ImageView implements RenderListener {
    private Drawable ˊ;
    private Drawable ॱ;

    public RenderMachineImageView(Context context) {
        super(context);
    }

    public RenderMachineImageView(Context context, @Nullable AttributeSet attributeSet) {
        super(context, attributeSet);
        ॱ(context);
    }

    public RenderMachineImageView(Context context, @Nullable AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ॱ(context);
    }

    private void ॱ(Context context) {
        this.ˊ = context.getResources().getDrawable(e.ˋᐝ);
        this.ॱ = context.getResources().getDrawable(e.ˌ);
    }

    public void setActive(boolean z) {
        if (z) {
            setBackground(this.ˊ);
        } else {
            setBackground(this.ॱ);
        }
    }

    public boolean onRenderReady(CSSViewProxy cSSViewProxy) {
        CSSRule rule = cSSViewProxy.getRule();
        if (rule.getStyleDeclaration() != null) {
            CSSValue propertyValue = rule.getStyleDeclaration().getPropertyValue(CSSPropertyName.BACKGROUND_TINT);
            if (propertyValue != null && (propertyValue instanceof CSSMonoColor)) {
                int color = ((CSSMonoColor) propertyValue).getColor();
                this.ˊ = epo.ॱ(this.ˊ, color);
                this.ॱ = epo.ॱ(this.ॱ, color);
            }
        }
        return false;
    }
}
